package com.guc.md

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.MenuItem
import android.view.View
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.guc.gviewbinding.inflate
import com.guc.md.databinding.ActivityBottomSheetBinding

/**
 * Created by Guc on 2021/5/27.
 * Description：BottomSheet 学习
 */
class BottomSheetActivity : AppCompatActivity(), View.OnClickListener {
    private val binding: ActivityBottomSheetBinding by inflate()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setSupportActionBar(binding.toolbar)
        supportActionBar?.run {
            setDisplayHomeAsUpEnabled(true)
            setHomeAsUpIndicator(R.drawable.icon_back)
        }
        binding.btnBSD.setOnClickListener(this)
        binding.btnBSDF.setOnClickListener(this)
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        this.finish()
        return super.onOptionsItemSelected(item)
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.btnBSD -> {
                val bs = BottomSheetDialog(this)
                bs.setContentView(R.layout.dialog_bs)
                bs.show()
            }
            R.id.btnBSDF -> {
                FullSheetDialogFragment().show(supportFragmentManager, "dialog")
            }
        }
    }
}